// Compilador.c : main project file.

#include "stdafx.h"
#include "token.h"
#include "lexical.h"
#include "error.h"


#include <stdlib.h>
#include <stdio.h>



int main()
{
	//FILE *p = fopen("pascal program.txt","r");
	//FILE *p = fopen("teste4.txt","r");

	FILE *p = fopen("massaTestesLexica.txt", "r");
	int initFile = InitFile(p);
	
	if(initFile == INVALID_FILE)
	{
		printf("%d", INVALID_FILE);
		getchar();
		return 0;
	}
	
	TOKEN *token; // = (TOKEN*) malloc (sizeof(TOKEN*));
	
	printf("token name\t token1\t token2\n\n");

	while(true)
	{
		token = (TOKEN*)next_token();
		ptrinttoken(token);
		if(!token)
		{
			//freetoken();
			return 2;
		}
		
		if(token->token1 == T_EOF)
		{
			//freetoken();
			break;
		}
		//if(!token) {printf("erro no token"); getchar(); return 2;}
		//if(token->token1 == T_EOF) break;
		//printf("%s\t", token->word);
		//printf("%d", token->token1);
		//if(token->token1 == 1) printf("\t%d", token->token2);
		//putchar('\n');
	}

	getchar();
	//freetoken();
    return 1;
}
